package com.site;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import tk.mybatis.spring.annotation.MapperScan;

@MapperScan("com.site.dao")
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        builder.sources(Application.class);
        return super.configure(builder);
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    /**
     * ======加载自定义名称的配置文件======
     * 方式一：加载自定义名称的配置文件时，properties文件使用@PropertySource注解即可，但该注解并不支持加载yaml
     * 方式二：就是下面方法
     *      加载自定义名称的 yml 配置文件
     *      将yaml文件转为properties并设置到属性源
     * @return
     */
    /*@Bean
    public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
        PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
        YamlPropertiesFactoryBean yamlProperties = new YamlPropertiesFactoryBean();
        yamlProperties.setResources(new ClassPathResource("test-application.yml"));
        propertySourcesPlaceholderConfigurer.setProperties(yamlProperties.getObject());
        return propertySourcesPlaceholderConfigurer;
    }*/
}
